package mutsumimod.monitors;

import basemod.interfaces.OnStartBattleSubscriber;
import com.megacrit.cardcrawl.actions.utility.DiscardToHandAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.rooms.AbstractRoom;
import mutsumimod.actions.CustomDrawPileToHandAction;
import mutsumimod.cards.stand.BecomeGod;

import java.util.Iterator;

public class PantheonizedHeroMonitor extends BaseMonitor implements OnStartBattleSubscriber {

    public static boolean isTriggered=false;

    @Override
    public void receiveOnBattleStart(AbstractRoom abstractRoom) {
        isTriggered=false;
    }


    public static void putPantheonizedHeroInHand() {
        if(isTriggered){
            return;
        }
        Iterator<AbstractCard> iterator = AbstractDungeon.player.discardPile.group.iterator();
        while (iterator.hasNext()) {
            AbstractCard card = iterator.next();
            if (card instanceof BecomeGod) {
                AbstractDungeon.actionManager.addToBottom(new DiscardToHandAction(card));
            }
        }

        iterator = AbstractDungeon.player.drawPile.group.iterator();
        while (iterator.hasNext()) {
            AbstractCard card = iterator.next();
            if (card instanceof BecomeGod) {
                AbstractDungeon.actionManager.addToBottom(new CustomDrawPileToHandAction(card));
            }
        }
        isTriggered=true;
    }
}
